import React from 'react';
import { Button, Checkbox, Form, Input } from 'antd';
import request from '../../../libs/request';
const Account = ({ setIsRegister }) => {


  const onFinish = values => {
    request.post('/api/v1/locker/sys-installs', {
      "install_key": "set_shop",
      "install_step": 3,
      "name": values.hotelName,
      "client_id": values.hotelId,
      "username": values.username,
      "password":values.password
    }).then(res => {
      console.log("注册结果",res)
      if(res.code == 0){

        alert("注册成功,首次登录账号和密码都是admin")
        setIsRegister(true)
      }else{
        alert(res.msg)

      }
    })
    
  };
  const onFinishFailed = errorInfo => {
    console.log('Failed:', errorInfo);

  };
  return (
    <Form
      name="basic"
      labelCol={{ span: 8 }}
      wrapperCol={{ span: 16 }}
      style={{ maxWidth: 600 }}
      initialValues={{ remember: true }}
      onFinish={onFinish}
      onFinishFailed={onFinishFailed}
      autoComplete="off"
    >

     

      <Form.Item
        label="酒店名称"
        name="hotelName"
        rules={[{ required: true, message: '请输入酒店名称!' }]}
      >
        <Input placeholder='请输入酒店名称' />
      </Form.Item>

 <Form.Item
        label="酒店id"
        name="hotelId"
        rules={[{ required: true, message: '请输入酒店id!' }]}
      >
        <Input placeholder='请输入酒店id' />
      </Form.Item>
      <Form.Item
        label="账号"
        name="username"
        rules={[{ required: true, message: '请输入账号!' }]}
      >
        <Input placeholder='请输入账号' />
      </Form.Item>

      <Form.Item
        label="密码"
        name="password"
        rules={[{ required: true, message: '请输入密码!' }]}
      >
        <Input.Password placeholder='请输入密码' />
      </Form.Item>

      <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
        <Button type="primary" htmlType="submit">
          提交
        </Button>
      </Form.Item>
    </Form>
  )
}
export default Account;